#ifndef DIALOGADDFOOD_H
#define DIALOGADDFOOD_H

#include <QDialog>
#include <QSqlDatabase>
#include <QSqlQueryModel>
#include <QSqlQuery>
#include <QDate>

#include "mealmodel.h"
#include "dialogmealdatamanage.h"

namespace Ui {
    class DialogAddFood;
}

class DialogAddFood : public QDialog
{
    Q_OBJECT

public:
    explicit DialogAddFood(DialogMealDataManage *mealManageDialog, QSqlDatabase *db, QWidget *parent = 0);
    ~DialogAddFood();
    void setDate(QDate date) {m_date = date;}
    void setType(MealModel::MealType type);

private:
    Ui::DialogAddFood *ui;
    QSqlQueryModel *m_model;
    QString m_queryBase;
    QSqlDatabase *m_db;
    DialogMealDataManage *m_mealManageDialog;
    QDate m_date;
    MealModel::MealType m_type;

    // filters
    int m_foodType;
    QString m_nameFilter;

    void updateFilter();

protected:
    void showEvent(QShowEvent *);

signals:
    void mealAdded();

private slots:
    void on_comboBoxFoodType_activated(int );
    void on_pushButtonAdd_clicked();
    void on_lineEditSearch_textChanged(const QString &);
    void on_tableViewFoods_clicked(const QModelIndex &index);
    void on_pushButtonEdit_clicked();
};

#endif // DIALOGADDFOOD_H
